/******************* (C) COPYRIGHT 2022 CHU WEI TENG ***********************************************
**
**------------------ File Info ---------------------------------------------------------------------
** File name:      uart_thread.h
** modified Date:  2022-05-10
** Last Version:   V1.0
** Descriptions: 
** 
**------------------ Modfication  log --------------------------------------------------------------
** Date       Who            Rev        Comments
----------------------------------------------------------------------------------------------------
   22/05/10 chuwt@qq.com    V1.00      created

****************************************************************************************************/
#include "uart_thread.h"
#include "dwin.h"

/* Private define----------------------------------------------------------------------------------*/

/* Private typedef---------------------------------------------------------------------------------*/

/* Private variables-------------------------------------------------------------------------------*/

void uart_thread(void *pvParameters)
{
    dwin_trans_init();

    dwin_trans_t* trans = dwin_trans_get();
    
    while (trans != NULL)
    {
        uint8_t     buf[128];
        uint16_t    len;
        data_pack_t pack;
        
        while(dwin_fifo_pop(trans->send_fifo, &pack))
        {
            dwin_uart_send(&pack, pack.length + 3);
        }
        
        while (len = dwin_uart_recv(buf))
        {
            dwin_trans_recv(trans, buf, len);
        }
        dwin_delay(10);
    }
    
}

